package net.aiion.weave.impl.messaging;

import net.aiion.weave.spi.injection.InjectionContext;
import net.aiion.weave.spi.injection.annotations.Inject;
import net.aiion.weave.spi.injection.annotations.Injects;
import net.aiion.weave.spi.messaging.MessageQueue;
import net.aiion.weave.spi.messaging.annotations.Queue;
import net.aiion.weave.spi.naming.Context;
import net.aiion.weave.spi.naming.annotations.Named;
import net.aiion.weave.spi.naming.annotations.NotScoped;

@Named
@NotScoped
public class MessageQueueInjector
{
    @Inject
    private Context namingContext;

    public MessageQueueInjector() {
    }

    @Injects(Queue.class)
    public MessageQueue createMessageQueue(final InjectionContext aInjectionContext) {
        return new MessageQueueImpl(namingContext, aInjectionContext.getTargetAnnotation(Queue.class).value());
    }
}
